package com.example.feilin.controller;

import com.example.feilin.entity.User;
import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Page;

public class UserController extends Controller {

	public void index() {
		render("list.html");
	}
	
	public void json() {
		Page<User> page = User.me.paginate(getParaToInt("page"), getParaToInt("pagesize"));
		renderJson(page);
	}
	
	public void form() {
		int act = getParaToInt("act");
		if (act == 3) {//修改数据
			setAttr("user", User.me.findById(getParaToInt("id")));			
		} else if (act == 2) {
			setAttr("user", User.me.set("age", 20).set("sex", true));
		}
		render("form1.html");
	}
	
	public void update() {
		getModel(User.class).save();
		redirect("/user");
	}
}
